import random
import car
import util
import config

class basicNode:

    def booleanToColor(self, b):
        if b == False:
            return (0, 0, 0)
        elif b == True:
            return (0,1,0)
        else:
            assert False

            
    def __init__(self,x,y,ID,isSafeNode = False, hasLights = False):
        self.radius = config.nodeRadius
        self.x = x
        self.y = y
        self.ID = "node" + str(ID)
        #self.inNeighbours = {}
        #self.outNeighbours = {}
        self.isSafeNode = isSafeNode
        self.color = (1, 1, 1)
        self.hasLights = hasLights
        self.redLightPhase = config.nodeLightEps
        self.greenLightPhase = config.nodeLightEps
        self.startEps = 0.0
        self.isRedLight = False       
        self.priority = 1 
        
    def __repr__(self):
        return "(" + str(self.x) + "," + str(self.y) + ")"

    def getXY(self):
        return (self.x, self.y)
    
    """
    def addInNeighbour(self,edge):
        assert self == edge.endNode
        self.inNeighbours[ edge.startNode ] = edge
    
    def addOutNeighbour(self,edge):
         assert self == edge.startNode
         self.outNeighbours[ edge.endNode ] = edge
    """
    
    def isInNode(self, x, y):
        return (self.x - x) ** 2 + (self.y - y) ** 2 <= self.radius ** 2    
     
    def getX(self):
        return self.x
    
    def getY(self):
        return self.y
